from Autotests.Suites.StressTest.Operations.PartnerOperations import PartnerOperations


class PartnersTree:

    def _addPartnersTree(self, manserv, parentId):
        for pantnerOnLevel in range(0, PartnerOperations()._partnersLevelCount):
            for key, value in PartnerOperations()._partnerLevelsPriority.items():
                self._createPartner(manserv, parentId, value)

    def _createPartner(self, manserv, parentId, partnerLevel):
        partnerId = PartnerOperations()._addPartner(manserv, parentId, partnerLevel)

        if partnerLevel != 'EndCustomer':
            for pantnerOnLevel in range(0, PartnerOperations()._partnersLevelCount):
                subLevel = PartnerOperations()._getPartnerSubLevel(partnerLevel)
                for key, value in PartnerOperations()._partnerLevelsPriority.items():
                    if PartnerOperations()._getPartnerLevelId(value) >=\
                            PartnerOperations()._getPartnerLevelId(subLevel):
                        self._createPartner(manserv, partnerId, value)
